package com.kanq.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kanq.common.utils.TitleGeneratorUtils;
import com.kanq.mapper.KanqAiHistoryMapper;
import com.kanq.pojo.entity.KanqAiHistory;
import com.kanq.pojo.response.HistoryConversation;
import com.kanq.service.KanqAiHistoryService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author wangchong
 * @description 针对表【kanq_ai_history】的数据库操作Service实现
 * @createDate 2025-06-04 14:16:21
 */
@Service
public class KanqAiHistoryServiceImpl extends ServiceImpl<KanqAiHistoryMapper, KanqAiHistory>
        implements KanqAiHistoryService {

    @Override
    public String generateTitle(String question) {
        return TitleGeneratorUtils.generateTitle(question);
    }

    @Override
    public void saveTitle(String userId, Long titleId, String title) {
        KanqAiHistory kanqAiHistory = new KanqAiHistory();
        kanqAiHistory.setHistoryId(titleId);
        kanqAiHistory.setTitle(title);
        kanqAiHistory.setUserId(userId);
        baseMapper.insert(kanqAiHistory);
    }

    @Override
    public IPage<KanqAiHistory> selectAllPage(Page<KanqAiHistory> objectPage, String userId) {
        return baseMapper.selectAllPage(objectPage, userId);
    }

    @Override
    public List<HistoryConversation> getHistoryConversationData(String userId, String conversationId) {
        return baseMapper.getHistoryConversationData(userId, conversationId);
    }
}




